home *** CD-ROM | disk | FTP | other *** search
- /* Flyer Auto-Calibration, Version 17-Dec-94, by SKell, NewTek Inc. */
- /* Updated and error checking added By Bob C. 26-Dec-95 */
-
- OPTIONS RESULTS
- numeric digits 12
-
- /*--------------------------------------------------------*/
- /* You may need to adjust these "assigns" for your system */
-
- TOAST = "Toaster:Programs/"
- FLYER = "Flyer_Support/C/"
-
- FLYER = TOAST||FLYER
-
- /*-------------------------------------------------*/
- /* Lets make sure they're not installed yet. */
-
- remlib("ToasterARexx.port")
- remlib("rexxmathlib.library")
-
- say "Flyer Auto-Calibration, Version 26-Dec-95"
- say
-
- IF exists(FLYER'PlayClip')=0 then do
- say "ERROR:"
- say " The file 'Toaster:Programs/Flyer_Support/C/PlayClip' is missing!"
- say " You may need to reinstall your flyer software."
- call GetOutaHere(" Flyer Calibration was not successful.")
- end
-
- if exists(FLYER'SetFloobyCal')=0 then do
- say "ERROR:"
- say " The File 'Toaster:Programs/Flyer_Support/C/SetFloobyCal' is missing!"
- say " You may need to reinstall your flyer software."
- call GetOutaHere(" Flyer Calibration was not successful.")
- end
-
- if exists(FLYER'CalibNew')=0 then do
- say "ERROR:"
- say " The file 'Toaster:Programs/Flyer_Support/C/CalibNew' is missing!"
- say " You may need to reinstall your flyer software."
- call GetOutaHere(" Flyer Calibration was not successful.")
- end
-
- if exists(FLYER'SetPlayMode')=0 then do
- say "ERROR:"
- say " The file 'Toaster:Programs/Flyer_Support/C/SetPlayMode' is missing!"
- say " You may need to reinstall your flyer software."
- call GetOutaHere(" Flyer Calibration was not successful.")
- end
-
- if exists(FLYER'voidall')=0 then do
- say "ERROR:"
- say " The file 'Toaster:Programs/Flyer_Support/C/Voidall' is missing!"
- say " You may need to reinstall your flyer software."
- call GetOutaHere(" Flyer Calibration was not successful.")
- end
-
- TestClip=""
-
- /*------------------------------------------*/
- if pos("ToasterARexx.port" , show('Ports'))=0 then do
-
- say
- say "Please wait for the Switcher to load."
-
-
- call pragma('d',TOAST)
-
- address command
- 'run >nil: VideoToaster'
- address
-
- /* Wait for the Switcher to come up */
-
- waitcount=0
- do while pos("ToasterARexx.port" , show('Ports'))=0
-
- address command
- 'wait 1'
- address
-
- waitcount = waitcount+1
-
- if(waitcount > 40) then do
- say "The Switcher Failed to Load!"
- say "Maybe you want to try again?"
- exit
- end
- end
- end
-
- addlib("ToasterARexx.port" , 0)
- SWITCHER(TOWB)
-
- /* The Switcher is now up and running */
- /*------------------------------------------*/
- /* calibrate the genlock */
-
- say "Calibrating the Flyer Genlock."
-
- address command
- FLYER'calibnew >nil: GC'
- 'c:wait 2'
- FLYER'SetFloobyCal >nil: 0 10 0 0' /* reset some stuff in the Flyer */
- address
-
- if ~exists("ENV:CalibResult") then do
- say
- say "ERROR:"
- say " The program CalibNew malfunctioned preventing me from calibrating"
- say " your Flyer. This could be caused by:"
- say
- say " 1) Incompatability with your currently installed Amiga OS."
- say " (I.E. system with an old mathieedoubbas.library in KickStart)"
- say " 2) Lack of a Flyer in your computer."
- say " 3) Your Flyer software not installed properly"
- say
- call GetOutaHere(" If the problem persists, contact NewTek for help.")
- end
-
- open(in,"ENV:CalibResult",'read')
- instring = readln(in)
- close(in)
- parse value instring with result
-
- if (result ~= 0.0) then do
- say
- say "ERROR:"
- say " A Problem was detected during Flyer genlock calibration."
- say " I got an error number of "result
- say " You may need to power down, and then try again."
- GetOutaHere(" If the problem persists, contact NewTek for help.")
- end
-
- /*------------------------------------------*/
-
- /* See if an existing TestSignal clip exists. If so, use it. */
- count=0
- volume=1
- do until((TestClip ~= "") | (volume=""))
- volume=SWITCHER(FLYV,count,1) /* see what Flyer Video volumes exist */
- count=count+1
-
- if(volume ~= "") then do
- clipname=value("volume")':TestSignal'
- if(exists(clipname)) then TestClip=clipname
- end
- end
-
- if(TestClip = "") then do
- say "Creating a Flyer Test Clip..."
-
- TestClip=SWITCHER(FLY1) /* create a test clip */
-
- if(TestClip="") then do
- say
- say "ERROR:"
- say " I was unable to create a Test Clip on one of your Flyer drives."
- say
- say " This could be caused by:"
- say " 1) Your Flyer drives are full."
- say " 2) No Flyer drive attached to your Flyer."
- say " 3) Flyer drives not mounted."
- say ""
- say " You may want to power down, and then try again."
- GetOutaHere(" If the problem persists, contact NewTek for help.")
- end
-
- say "Created '"TestClip"' test clip."
- end
-
- /**********************************/
-
- address command
- FLYER'playclip >nil: 0 0 0 "'TestClip'" 0 0 0 1 0'
- address
-
- SWITCHER(TOSW)
- SWITCHER(M003)
- SWITCHER(P003)
-
- if(ConnectLoopBack()=FALSE) then do
-
- /* see if the user ever did any autohue */
- if(SWITCHER(STAT,DHUE) < 0) then do
- /* The user has never AutoHued their Toaster, so set Digital Phase */
-
- say "Calibrating the Toasters digital phase."
- best=CaliDigitalPhase()
- SWITCHER(DHUE,best+256)
- SWITCHER(MKHS)
- end
- else do
- /* is the current Digital Phase Error > 3 degrees = (65536*sine(error)) ?*/
- if(abs(SWITCHER(DH3E)) > 3430) then do
- SWITCHER(TOWB)
- say "Do you have a video source connected to input 1 of your Toaster (y/n)?"
- pull myhair
- if (left(myhair,1) ~= "N") then do
- say "Your Toaster may need AutoHueing."
- say "You should Quit this script, AutoHue the Toaster,"
- say "and then run this script again."
- say "Do you want to continue this script anyway (y/n)?"
- pull myhair
- if (left(myhair,1) ~= "Y") then do
- SWITCHER(TOSW)
- SWITCHER(NOIQ)
- SWITCHER(TOWB)
- remlib("ToasterARexx.port")
- exit
- end
- else do
- say "WARNING!"
- say "Because you have chosen to skip Toaster AutoHueing,"
- say "your Flyers playback hue may not be calculated accurately."
- end
- end
-
- say "Is it OK for me to adjust your Toaster Digital Hue (y/n)?"
- pull myhair
- SWITCHER(TOSW)
-
- if (left(myhair,1) ~= "N") then do
- say "Calibrating the Toasters digital phase."
- best=CaliDigitalPhase()
- SWITCHER(DHUE,best)
- SWITCHER(MKHS)
- end
- end
- end
-
- DigitalPhaseError = DeltaHue2Angle(SWITCHER(DH3E))
-
- if(abs(DigitalPhaseError) > 5) then do
- SWITCHER(TOWB)
- say "Your Toaster has a Digital Hue error of "DigitalPhaseError" degrees."
- say "So, the Flyer's playback phase may not be calibrated correctly!"
- say "You should try AutoHueing your Toaster, and then repeat this script."
- SWITCHER(TOSW)
- end
- end
-
- /*------------------------------------------*/
-
- say "Please wait. Calibrating the Flyer's Record Phase."
-
- SWITCHER(MDV2)
- SWITCHER(PDV1) /* tell it to load into DV1 */
- SWITCHER(PAT1) /* Generatate test signal into DV1 */
- SWITCHER(MDV1)
- SWITCHER(PDV1)
- SWITCHER(TOWB)
-
-
- /*******************/
- /* Auto Record Hue */
- address command
- FLYER'CalibNew >nil: AR 2'
- FLYER'SetPlayMode 0 PLAY'
- address
-
- if ~exists("ENV:CalibResult") then do
- say
- say "ERROR:"
- say " The program CalibNew malfunctioned preventing me from calibrating"
- say " your Flyer. This could be caused by:"
- say
- say " 1) Incompatability with your currently installed Amiga OS."
- say " (I.E. system with an old mathieedoubbas.library in KickStart)"
- say " 2) Lack of a Flyer in your computer."
- say " 3) Your Flyer software not installed properly"
- say
- call GetOutaHere(" If the problem persists, contact NewTek for help.")
- end
-
- open(in,"ENV:CalibResult",'read')
- instring = readln(in)
- close(in)
- parse value instring with RecordPhaseError
-
- /*------------------------------------------*/
- SWITCHER(TOSW)
-
- say "Calibrating the Flyer's Playback Phase on channel 0."
- Play0PhaseError=CalibratePlay(0)
-
- say "Calibrating the Flyer's Playback Phase on channel 1."
- Play1PhaseError=CalibratePlay(1)
-
- address command
- 'echo >ENV:FlyerCalibResults 'DigitalPhaseError RecordPhaseError Play0PhaseError Play1PhaseError
- /* 'type ENV:FlyerCalibResults' */
- 'delete >NIL: "'TestClip'"'
- address
-
- Switcher(TOWB)
-
- say "Cleaning up Flyer drives..."
-
- address command
- FLYER'voidall >NIL:'
- address
-
- GetOutaHere("Flyer Calibration was successful.")
- exit
-
- /******************************************************************/
- /******************************************************************/
- CalibratePlay:
- arg VidChannel
-
- if(VidChannel=0) then do
- SWITCHER(M003)
- SWITCHER(P003)
- grab=IQ30
- end
- else do
- SWITCHER(M004)
- SWITCHER(P004)
- grab=IQ40
- end
-
- /*-----------*/
- address command
- 'c:copy >nil: 'FLYER'SetFloobyCal RAM: quiet'
- FLYER'playclip >nil: 0 'VidChannel' 0 "'TestClip'" 0 0 0 1 0'
- 'RAM:SetFloobyCal >nil: 'VidChannel' 2 0 0 0 0'
- address
- /*-----------*/
-
- SWITCHER(DIIM) /* disable imagery */
-
- QabsBest= 500000000 /* bogus initial value */
- Position=-35
-
- do until ((PlayPhaseError < 3) | (Position=0))
- if(Position=-34) then posit="ffde"
- else if(Position=-35) then posit="ffdd"
- else if(Position=-36) then posit="ffdc"
-
- /* set play position */
- address command
- 'RAM:SetFloobyCal >nil: 'VidChannel' 5 0 'posit
- address
-
- do clock=0 to 3
- do coarse=0 to 9
- do fine=0 to 7
- address command
- 'RAM:SetFloobyCal >nil: 'VidChannel' 2 0 'clock coarse fine
- address
-
- result=SWITCHER(value(grab))
- parse value result with 1 YPI +4 YPQ +4 YNI +4 YNQ +4
- I0= c2d(YPI)-c2d(YNI)
- Q0= c2d(YPQ)-c2d(YNQ)
- Qabs = abs(Q0)
-
- if((Qabs < QabsBest) & (I0 > 0)) then do
- PositionBest=Position
- positBest=posit
- Ibest=I0
- Qbest=Q0
- QabsBest=Qabs
- ClockBest=clock
- CoarseBest=coarse
- FineBest=fine
- end
- end fine
- end coarse
- end clock
-
- if(Position=-35) then Position=-34
- else if(Position=-34) then Position=-36
- else if(Position=-36) then Position=0
-
- PlayPhaseError = IQ2Hue(Ibest,Qbest)
- end
-
- SWITCHER(ENIM) /* enable imagery */
-
- /* say "Clock Coarse Fine ="PositionBest ClockBest CoarseBest FineBest */
-
- if(abs(PlayPhaseError) > 3) then do
- testit:
- say
- say "ERROR:"
- say " A problem was detected during Flyer Play Phase calibration."
- say " the Play Phase error was "PlayPhaseError" degrees."
- say " You may need to power down, and then try again."
- say
- GetOutaHere(" If the problem persists, contact NewTek for help.")
- end
-
- /* save it in non-volatile memory */
- address command
- 'RAM:SetFloobyCal >nil: 'VidChannel' 5 1 'positBest
- 'RAM:SetFloobyCal >nil: 'VidChannel' 2 1 'ClockBest CoarseBest FineBest
- 'c:delete >nil: RAM:SetFloobyCal quiet'
- address
-
- return (PlayPhaseError)
-
- /******************************************************************/
- /******************************************************************/
- ConnectLoopBack:
- abort=FALSE
- SWITCHER(TOSW)
-
- do while((abort=FALSE) & (SWITCHER(STAT,V2IS) = 0))
- SWITCHER(TOWB)
- say "Please connect the output of your Toaster to the Toasters Input 2."
- say "Please press <RETURN> when ready. (or enter 'A' to abort)"
- pull myhair
-
- if (left(myhair,1) = "A") then do
- abort=TRUE
- say
- say "WARNING:"
- say " Toaster Digital Hue adjustment has been aborted."
- say " Your Flyer's playback phase may not be calibrated correctly!"
- end
-
- SWITCHER(TOSW)
- end
- return(abort)
-
- /******************************************************************/
- /******************************************************************/
- CaliDigitalPhase:
-
- abserr=130000 /* bogus error */
-
- do dp=0 to 63
- SWITCHER(DHUE,dp)
- /* SWITCHER(M003) */
- dperr=SWITCHER(DH3E) /* signed error */
- absdp=abs(dperr)
-
- if(absdp < abserr) then do
- error=dperr
- abserr=absdp
- best=dp
- end
- end
-
- /* say "BestDP="best" Error="error */
-
- return(best)
-
- /******************************************************************/
- /******************************************************************/
- /* -180 < result < 180 degrees */
- polar: procedure
- arg opposite,adjacent
-
- if adjacent = 0 then do
- if opposite < 0 then return 270
- else return 90
- end
-
- remlib("ToasterARexx.port")
- addlib("rexxmathlib.library",0,-30,0)
- result = 57.29578*atan(opposite/adjacent)
- remlib("rexxmathlib.library")
- addlib("ToasterARexx.port",0)
-
- if adjacent < 0 then result = result + 180
- return result
-
- /******************************************************************/
- /******************************************************************/
- IQ2Hue: procedure
- arg ip,qp
-
- hue = polar(-qp,ip) /* return degrees from I vector */
- return hue
-
- /******************************************************************/
- /******************************************************************/
- DeltaHue2Angle: procedure
- arg foo
-
- foo = foo/65536
- if (( foo > 1.0 ) | (foo < -1.0)) then result = 3.1416*sign(foo) + arcsine(foo-2*sign(foo))
- else result = arcsine(foo)
- return 57.29578*result
-
- /******************************************************************/
- squareroot: procedure
- arg param
-
- remlib("ToasterARexx.port")
- addlib("rexxmathlib.library",0,-30,0)
- result = sqrt(param)
- remlib("rexxmathlib.library")
- addlib("ToasterARexx.port",0)
- return result
-
- /******************************************************************/
- arcsine: procedure
- arg param
-
- remlib("ToasterARexx.port")
- addlib("rexxmathlib.library",0,-30,0)
- result = asin(param)
- remlib("rexxmathlib.library")
- addlib("ToasterARexx.port",0)
- return result
-
-
- /******************************************************************/
- /******************************************************************/
-
- GetOutaHere:
- parse arg message
-
- remlib("ToasterARexx.port")
- if show('Ports',"ToasterARexx.port") then addlib("ToasterARexx.port" , 0)
- if show('Ports',"ToasterARexx.port") then do
- Switcher(TOSW)
- SWITCHER(NOIQ)
- SWITCHER(TOWB)
- end
-
- say message
-
- /**********
- if(TestClip ~= "") then do
- say "Would you like me to delete the "TestClip" clip (Y/N)?"
- pull myhair
- if (left(myhair,1) ~= "N") then do
- address command
- 'c:delete >nil: 'TestClip' quiet'
- address
- end
- end
- else do
- say
- say "Press <RETURN> to exit."
- pull myhair
- end
- **********/
-
- say
- say "Press <RETURN> to exit."
- pull myhair
- if show('Ports',"ToasterARexx.port") then remlib("ToasterARexx.port")
- exit
- return
-